
<%@ page import="com.surelution.projects.crm.Market" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'market.label', default: 'Market')}" />
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
    	<div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
        </div>
        <div class="body">
            <h1><g:message code="default.list.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                        
                            <g:sortableColumn property="id" title="${message(code: 'market.id.label', default: 'Id')}" />
                        
                            <g:sortableColumn property="area" title="${message(code: 'market.area.label', default: 'area')}" />
                        
                            <g:sortableColumn property="name" title="${message(code: 'market.name.label', default: 'Name')}" />

                            <g:sortableColumn property="cardType" title="${message(code: 'market.cardType.label', default: 'CardType')}" />

                            <g:sortableColumn property="marketType" title="${message(code: 'market.marketType.label', default: 'marketType')}" />

                            <g:sortableColumn property="manager" title="${message(code: 'market.manager.label', default: 'manager')}" />

                            <g:sortableColumn property="managerTel" title="${message(code: 'market.managerTel.label', default: 'managerTel')}" />

                            <g:sortableColumn property="isLocked" title="${message(code: 'market.isLocked.label', default: 'isLocked')}" />

                            <g:sortableColumn property="operation" title="${message(code: 'market.operation.label', default: 'operation')}" />
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${marketInstanceList}" status="i" var="marketInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <td><g:link action="show" id="${marketInstance.id}">${fieldValue(bean: marketInstance, field: "id")}</g:link></td>

                            <td>${fieldValue(bean: marketInstance, field: "area.areaName")}</td>

                            <td>${fieldValue(bean: marketInstance, field: "name")}</td>

                            <td>${marketInstance?.cardType}</td>

                            <td>${fieldValue(bean: marketInstance, field: "marketType.type")}</td>

                            <td>${fieldValue(bean: marketInstance, field: "manager")}</td>

                            <td>${fieldValue(bean: marketInstance, field: "managerTel")}</td>
                        
                            <td><g:formatBoolean boolean="${marketInstance.isLocked}" /></td>

                            <td>
								<g:form>
				                    <g:hiddenField name="id" value="${marketInstance?.id}" />
				                    <g:if test="${marketInstance.isLocked==true}">
				                    	<span class="button"><g:actionSubmit class="unLock" action="unLock" value="${message(code: 'default.button.unLocked.label', default: 'unLocked')}" onclick="return confirm('${message(code: 'default.button.unLocked.confirm.message', default: 'Are you sure?')}');" /></span>
				                	</g:if>
				                	<g:if test="${marketInstance.isLocked==false}">
				                    	<span class="button"><g:actionSubmit class="locked" action="locked" value="${message(code: 'default.button.locked.label', default: 'locked')}" onclick="return confirm('${message(code: 'default.button.locked.confirm.message', default: 'Are you sure?')}');" /></span>
				                	</g:if>
				                </g:form>
                            </td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${marketInstanceTotal}" />
            </div>
        </div>
    </body>
</html>
